<html>
<head><meta charset="utf-8"><title>Change `ty::Const` to an integer tree repr compiler-team#323 · t-compiler/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/index.html">t-compiler/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html">Change `ty::Const` to an integer tree repr compiler-team#323</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202544646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202544646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202544646">(Jul 01 2020 at 08:49)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/compiler-team/issues/323">#323</a>. It will be<br>
                announced at the next meeting to try and draw attention to it,<br>
                but usually MCPs are not discussed during triage meetings. If<br>
                you think this would benefit from discussion amongst the<br>
                team, consider proposing a design meeting.</p>



<a name="202546045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546045">(Jul 01 2020 at 09:06)</a>:</h4>
<p>Nice <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span></p>



<a name="202546329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546329">(Jul 01 2020 at 09:10)</a>:</h4>
<blockquote>
<p>Move parts from <code>ConstKind</code> to <code>ConstValue</code>, allowing things like <code>(42, N)</code> to be encoded, while currently const generic parameters can only be encoded if the constant is just a const generic parameter directly.</p>
</blockquote>
<p><span class="user-mention" data-user-id="124288">@oli</span>  Can you give an example where this is useful? I think we currently either have fully monomorphic <code>ConstKind</code>s and things like <code>(42, N)</code> are represented as <code>ConstKind::Unevaluated</code>. I didn't yet think too deeply about this, but are there some patterns that are hard/impossible without this possible future change?</p>



<a name="202546504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546504">(Jul 01 2020 at 09:12)</a>:</h4>
<p>We may want to not represent them as <code>ConstKind::Unevaluated</code>. I don't really know <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span> I am mainly mentioning it for completeness</p>



<a name="202546534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546534">(Jul 01 2020 at 09:12)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="121053">@varkor</span></p>



<a name="202546591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546591">(Jul 01 2020 at 09:13)</a>:</h4>
<p>It might be required if we want to be able to unify <code>(42, N)</code> with <code>(42, M)</code> and infer <code>N == M</code>, which isn't possible rn but might be desirable in the future</p>



<a name="202546859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546859">(Jul 01 2020 at 09:17)</a>:</h4>
<blockquote>
<p>Duplicate ty::Const into ty::Const and mir::Const where the former becomes a tree with integer leaves and the latter loses all forms of “optimized” representation and just refers to the plain const allocation backing the constant.</p>
</blockquote>
<p>That would mean that a <code>mir::Const</code> representing <code>42u8</code> suddenly gets an <code>Allocation</code> allocated instead of using <code>ConstValue::Scalar</code>, thus increasing the memory usage. Probably by a significant amount.</p>



<a name="202546960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546960">(Jul 01 2020 at 09:18)</a>:</h4>
<p>Wouldn't <code>42u8</code> be just represented as <code>ConstValue::Leaf(42u128)</code>?</p>



<a name="202546974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202546974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202546974">(Jul 01 2020 at 09:18)</a>:</h4>
<p>That is for <code>ty::Const</code>, not for <code>mir::Const</code>.</p>



<a name="202547209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202547209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202547209">(Jul 01 2020 at 09:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323/near/202546859">said</a>:</p>
<blockquote>
<blockquote>
<p>Duplicate ty::Const into ty::Const and mir::Const where the former becomes a tree with integer leaves and the latter loses all forms of “optimized” representation and just refers to the plain const allocation backing the constant.</p>
</blockquote>
<p>That would mean that a <code>mir::Const</code> representing <code>42u8</code> suddenly gets an <code>Allocation</code> allocated instead of using <code>ConstValue::Scalar</code>, thus increasing the memory usage. Probably by a significant amount.</p>
</blockquote>
<p>This <em>already</em> happens, we just throw the reference to it away.</p>



<a name="202547231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202547231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202547231">(Jul 01 2020 at 09:21)</a>:</h4>
<p><code>const_eval_raw</code> will give you an <code>&amp;'tcx Allocation</code> to the constant</p>



<a name="202547268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202547268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202547268">(Jul 01 2020 at 09:21)</a>:</h4>
<p><code>const_eval_validated</code> invokes <code>const_eval_raw</code>, thus causing this allocation to always be created</p>



<a name="202547609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/202547609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#202547609">(Jul 01 2020 at 09:25)</a>:</h4>
<p>so incremental caches aren't affected by this change, but it may have an effect on the size of the MIR encoded in metadata, since that currently indeed does not create an <code>Allocation</code> for integer constants. I'll make sure to do this change as its own PR and check the size of artifacts</p>



<a name="203015736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203015736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203015736">(Jul 06 2020 at 17:09)</a>:</h4>
<blockquote>
<p>A lossy conversion from mir::Const to ty::Const will be introduced. It will be used for pretty printing mir::Const during mir dumps. This way we only have to support pretty printing ty::Const, which is trivial to pretty print.</p>
</blockquote>
<p>what do you plan to do for types not representable in <code>ty::Const</code>? After all, one key point here is that not all types fit <code>ty::Cosnt</code> -- but the consumers of <code>ty::Const</code> cannot properly support those types anyway.<br>
examples include unions and raw pointers.</p>



<a name="203015827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203015827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203015827">(Jul 06 2020 at 17:10)</a>:</h4>
<p>re: the concrete <code>ConstValue</code>, I wonder if <code>Leaf</code> should have a <code>size</code> information like <code>Scalar::Raw</code> does. it served us well there.</p>



<a name="203016065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203016065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203016065">(Jul 06 2020 at 17:13)</a>:</h4>
<p>also could the hackmd describe how the queries will be organized (re: <a href="https://github.com/rust-lang/rust/issues/72396">https://github.com/rust-lang/rust/issues/72396</a>)?<br>
my expectation is that there will be one query that everything goes through that returns a <code>mir::Const</code> after validating type-based invariants. and then there is a second query that returns a <code>ty::Const</code> but this can fail if the type of the const is not fit for integer trees. (or if the values does not match the type, which can still happen behind static indirections -- where validation has to stop to avoid query cycles.)</p>



<a name="203087883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203087883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203087883">(Jul 07 2020 at 10:45)</a>:</h4>
<p>I didn't add that part to the MCP as it's technically an orthogonal refactoring to move validation to the raw query</p>



<a name="203087963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203087963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203087963">(Jul 07 2020 at 10:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323/near/203015827">said</a>:</p>
<blockquote>
<p>re: the concrete <code>ConstValue</code>, I wonder if <code>Leaf</code> should have a <code>size</code> information like <code>Scalar::Raw</code> does. it served us well there.</p>
</blockquote>
<p>I left it out on purpose, but we could keep it in initially to keep the change from the current system small</p>



<a name="203087981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203087981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203087981">(Jul 07 2020 at 10:47)</a>:</h4>
<p>Types not representable in <code>ty::Const</code> get printed via the <code>Allocation</code> printing</p>



<a name="203291563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203291563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203291563">(Jul 08 2020 at 16:41)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="492">@T-compiler</span>: Proposal <a href="https://github.com/rust-lang/compiler-team/issues/323#issuecomment-655630894">#323</a> has been seconded, and will be approved in 10 days if no objections are raised.</p>



<a name="203638448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203638448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203638448">(Jul 12 2020 at 10:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323/near/203087963">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323/near/203015827">said</a>:</p>
<blockquote>
<p>re: the concrete <code>ConstValue</code>, I wonder if <code>Leaf</code> should have a <code>size</code> information like <code>Scalar::Raw</code> does. it served us well there.</p>
</blockquote>
<p>I left it out on purpose, but we could keep it in initially to keep the change from the current system small</p>
</blockquote>
<p>what is the reasoning for not doing size tracking any more?</p>



<a name="203639715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203639715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203639715">(Jul 12 2020 at 11:29)</a>:</h4>
<p>mostly memory usage, iirc this is the main reason we can't shrink <code>ConstValue</code> down any more, and considering that the most common value is <code>usize</code> and <code>bool</code>, it seems very wasteful. Maybe I should figure out some other representation where <code>u128</code> is behind a box or sth. Anyway, let's keep it in and table the discussion until we actually try to remove the <code>size</code> field.</p>



<a name="203683426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203683426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203683426">(Jul 13 2020 at 07:04)</a>:</h4>
<p>(FWIW since this is outside Miri I'd be okay to remove the size field if you want to go that route, we'd still get our sanity checks during evaluation. I just wanted to understand why it is worth dropping the safety net.)</p>



<a name="203683914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203683914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203683914">(Jul 13 2020 at 07:13)</a>:</h4>
<p>you could have <code>u128</code> and <code>i128</code> leaves, tbh</p>



<a name="203683963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203683963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203683963">(Jul 13 2020 at 07:14)</a>:</h4>
<p>so that the "abstract value" is represented, no encoding signed integers into <code>u128</code></p>



<a name="203683998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203683998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203683998">(Jul 13 2020 at 07:15)</a>:</h4>
<p>(and presumably "byte array" leaves for <code>"..."</code> and <code>b"..."</code> literals :P)</p>



<a name="203684841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203684841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203684841">(Jul 13 2020 at 07:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323/near/203683963">said</a>:</p>
<blockquote>
<p>so that the "abstract value" is represented, no encoding signed integers into <code>u128</code></p>
</blockquote>
<p>avoiding signedness issues would be awesome indeed</p>



<a name="203684867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203684867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203684867">(Jul 13 2020 at 07:27)</a>:</h4>
<p>but if we have<code>u128</code>/<code>i128</code> that means we need a tag and that means we likely have enough space for the size</p>



<a name="203684960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203684960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203684960">(Jul 13 2020 at 07:28)</a>:</h4>
<p>eddyb means to make these not sub-enums of the <code>Leaf</code> variant, but just add multiple <code>Leaf</code> variants</p>



<a name="203684992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203684992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203684992">(Jul 13 2020 at 07:29)</a>:</h4>
<p>sure</p>



<a name="203684994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203684994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203684994">(Jul 13 2020 at 07:29)</a>:</h4>
<p>though at that point you're right, we may be able to reuse the space in the tag, since the tag will do a bump to requiring another <code>usize</code> bytes</p>



<a name="203685181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203685181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203685181">(Jul 13 2020 at 07:32)</a>:</h4>
<p>and the "size" is just an <code>u8</code>, right?</p>



<a name="203685245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203685245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203685245">(Jul 13 2020 at 07:33)</a>:</h4>
<p>yeah, until we have integers longer than 255 bytes^^</p>



<a name="203685253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Change%20%60ty%3A%3AConst%60%20to%20an%20integer%20tree%20repr%20compiler-team%23323/near/203685253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Change.20.60ty.3A.3AConst.60.20to.20an.20integer.20tree.20repr.20compiler-team.23323.html#203685253">(Jul 13 2020 at 07:33)</a>:</h4>
<p>but even then we could just encode log2(size)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>